import {
  HTTP
} from '../utils/http.js'

class GoodsSaleModel extends HTTP {
  // 商品销量统计
  goodsSale(start, end,page,pagesize,sCallback) {
    this.request({
      url: 'order/goodsSaleRank',
      data: {
        "start_time": start,
        "end_time": end,
        "page":page,
        "pagesize":pagesize
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      method: 'POST',
      success: (data) => {
        sCallback(data)
      }
    })
  }

  // 每日订单统计
  static(start,end,phone,page=1,pagesize=20,sCallback) {
    this.request({
      url: 'order/OrderInfoStat',
      data: {
        "start_time": start,
        "end_time": end,
        "page": page,
        "pagesize": pagesize,
        "phone": phone
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      method: 'POST',
      success: (data) => {
        sCallback(data)
      }
    })
  }

  // 商品推荐统计
  goodsRecommend(userID, sCallback) {
    this.request({
      url: 'order/getGoodsRecommend?user_id='+userID,
      header: {
        'content-type': 'application/json' // 默认值
      },
      method: 'GET',
      success: (data) => {
        sCallback(data)
      }
    })
  }

  // 后台赠送银豆
  adminSendSilver(data, sCallback) {
    return this.request({
      url: `silver/send_silver`,
      method: 'POST',
      data: data,
      success: (data) => {
        sCallback(data)
      }
    })
  }
}

export { GoodsSaleModel }